package cn.dnuihyy406.dnuifood_16110100406.controller.getfood;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import cn.dnuihyy406.dnuifood_16110100406.R;
import cn.dnuihyy406.dnuifood_16110100406.bean.GetCommentBean;

public class GetCommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements View.OnClickListener {
    private Context mContext;
    private List<GetCommentBean> commentlist;
    private LayoutInflater mLayoutInflater;
    //    private ShopAdapter.OnRecyclerViewItemClickListenr mOnItemClickListener = null;
    public GetCommentsAdapter(Context mContext,List commentlist){
        this.mContext=mContext;
        this.commentlist=commentlist;
        mLayoutInflater=LayoutInflater.from(mContext);
        notifyDataSetChanged();
    }

    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {

        View v=mLayoutInflater.from(viewGroup.getContext()).inflate(R.layout.comment_item,viewGroup,false);
//        v.setOnClickListener(this);
        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder Holder, int i) {
        final GetCommentBean x=commentlist.get(i);
        if (null==x){
            return;
        }
        ViewHolder viewHolder=(ViewHolder)Holder;
        viewHolder.foodid.setText(x.getFood_id());
        viewHolder.comment_time.setText(x.getComment_time());
        viewHolder.content.setText(x.getContent());
    }

    //setText数据显示


    @Override
    public int getItemCount() {
        return commentlist.size();
    }

    @Override
    public void onClick(View view) {

    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        TextView foodid,comment_time,content;


        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            foodid= itemView.findViewById(R.id.food_id);
            comment_time = itemView.findViewById(R.id.comment_time);
            content = itemView.findViewById(R.id.content1);


        }
    }
}